package com.example.administrator.myapplication;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.administrator.myapplication.util.DB;

/**
 * Created by Administrator on 2020/12/10.
 */

public class SignInActivity extends AppCompatActivity {

    private EditText signInusernameEt;
    private EditText signInstudentEt;
    private Button signInBtn;
    private String usernameStr;
    private String studentidStr;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_in);
        initView();
        initEvent();
    }

    private void initView() {
        signInusernameEt = findViewById(R.id.sign_in_username_et);
        signInstudentEt = findViewById(R.id.sign_in_student_id_et);
        signInBtn = findViewById(R.id.sign_in_btn);

    }

    private void initData() {
        usernameStr = signInusernameEt.getText().toString() + "";
        studentidStr = signInstudentEt.getText().toString() + "";

    }

    private void initEvent() {
        signInBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                initData();
                DB db = new DB(SignInActivity.this);
                db.signInInsert(usernameStr, studentidStr);
                Toast.makeText(SignInActivity.this, ""+usernameStr+""+studentidStr, Toast.LENGTH_SHORT).show();
            }
        });


    }
}
